using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerWallSlideState : PlayerState
{
    public PlayerWallSlideState(Player player, StateMachine<PlayerState> stateMachine, string animBoolName) : base(player, stateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();

        if ( ( !Mathf.Approximately(xInput,0f) && player.facingDir * xInput < 0) || !player.IsWallDetected()) 
        {
            stateMachine.ChangeState(player.idleState);
            return;
        }

        if (KeyInputManager.GetJumpKeyDown()) 
        {
            stateMachine.ChangeState(player.wallJumpState);
            return;
        }

        if (yInput < 0)
        {
            player.SetVelocity(rb.velocity.x, -player.slideInWallMaxSpeed);
        }
        else
        {
            player.SetVelocity(rb.velocity.x, -player.slideInWallMinSpeed);
        }
    }
}
